
import { defineStore } from 'pinia'
import { requestSearchPoemsListDetailByPlId, requestCollectPoems, requestEditPoemsListInfo, queryCollectPoemsInfo } from './poems-detail.api'

export default defineStore('poemsDetail', {
    state: () => {
        return {
            
        }
    },
    getters: {
    },
    actions: {
        // 根据id获取诗单详情
        searchPoemsListDetailByPlId(data: any) {
            return new Promise((resolve, reject) => {
                requestSearchPoemsListDetailByPlId(data).then(response => {
                    const res: any = response.data
                    if (res.code === 200) {
                        resolve(res.data)
                    }
                })
            })
        },
        // 收藏诗单
        collectPoems(data: any) {
            return new Promise((resolve, reject) => {
                requestCollectPoems(data).then(response => {
                    const res: any = response.data
                    if (res.code === 200) {
                        resolve(res.data)
                    }
                })
            })
        },
        // 查询收藏信息
        queryCollectPoemsInfo(data: any) {
            return new Promise((resolve, reject) => {
                queryCollectPoemsInfo(data).then(response => {
                    const res: any = response.data
                    if (res.code === 200) {
                        resolve(res.data)
                    }
                })
            })
        },
        // 编辑诗单
        editPoemsListInfo(formData: any, poemsListInfo: any) {
            return new Promise((resolve, reject) => {
                requestEditPoemsListInfo(formData, poemsListInfo).then(response => {
                    const res: any = response.data
                    if (res.code === 200) {
                        resolve(res.data)
                    }
                })
            })
        },
    }
})
